﻿using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.ServiceModel.Web;
using UFIDA.U9.WSS.ProxyService.Behavior.WebHttp.Base;

namespace UFIDA.U9.WSS.ProxyService.Behavior.WebHttp
{
    public class GeneralServiceBehavior : NewtonsoftJsonBehavior
    {
        private readonly bool _useDataContract;

        public GeneralServiceBehavior(bool useDataContract = false)
        {
            _useDataContract = useDataContract;
        }

        protected override IDispatchMessageFormatter GetCustomDispatchFormatter(
            OperationDescription operationDescription)
        {
            WebMessageBodyStyle bodyStyle = GetBodyStyle(operationDescription);
            return new GeneralServiceDispatchFormatter(operationDescription, bodyStyle, _useDataContract);
        }
    }
}